﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Windsor;
using Castle.MicroKernel.Registration;
using NHibernate;
using Castle.Facilities.FactorySupport;

namespace MM.Bootstrapper.Configurators
{
    public class NHibernateConfigurator : IConfigurator
    {
        #region Miembros de IConfigurator

        public void Configure(IWindsorContainer container) {

            
            //PROBADO EN PRODUCCION
            //container.Register(Component.For<SessionFactoryProvider>()
            //                    .ImplementedBy<SessionFactoryProvider>()
            //                    .LifeStyle.Singleton
            //                    );

            //container.Register(Component.For<ISessionFactory>()
            //                    .UsingFactoryMethod(
            //                      kernel =>
            //                        kernel.Resolve<SessionFactoryProvider>().BuildSessionFactory())
            //                    .LifeStyle.Singleton);

            container.Register(
                Component.For<ISessionFactory>()
                .Instance(new SessionFactoryProvider().BuildSessionFactory())
                );

        }

        #endregion


        
    }
}
